<template>
    <div>
        <el-card class="box-card oplog-crad">
            <div slot="header" class="clearfix">
                <span>操作日志</span>
            </div>
            <div class="text item">
                <el-table
                        v-loading="loading"
                        :data="oplogs"
                        style="width: 100%">
                    <el-table-column
                            prop="username"
                            label="操作人"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="operation"
                            label="操作名"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="ip"
                            label="ip地址"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="createDate"
                            label="操作时间">
                    </el-table-column>
                </el-table>
                <div class="page">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page.sync="currentPage3"
                            :page-size="10"
                            layout="prev, pager, next, jumper"
                            :total="pageTotal">
                    </el-pagination>
                </div>
            </div>
        </el-card>
    </div>

</template>

<script>
    export default {
        name: "SysLog",
        data(){
            return{
                oplogs:[],
                pageTotal:0,
                loading:false
            }
        },
        methods:{
            initOplog(){
                this.getRequest("/system/oplog/").then(resp=>{
                    if (resp){
                        this.oplogs = resp.data;
                        this.pageTotal= resp.total;
                    }
                })
            },
            handleCurrentChange(val) {
                this.loading = true;
                this.getRequest("/system/oplog/?page="+(val-1)*10).then(resp=>{
                    if (resp){
                        this.loading = false;
                        this.oplogs = resp.data;
                        this.pageTotal= resp.total;
                    }
                })
            }
        },
        mounted() {
            this.initOplog();
        }
    }
</script>

<style>
.page{
    margin-top: 10px;
    display: flex;
    justify-content: center;
}
    .oplog-crad{
        width: 800px;
    }
</style>